﻿/*版权声明
 * 
 * 本 WebName:IMIS_ERP 由
 * 河北大学 信管团队 开发
 * 如有任何疑问请联系开发人员
 * 
 * 项目开发者
 * 负责人：朱胜贤
 * 成员：水亚亚、孙旭峰、张文元、项玥、吕芳、吴凡、谢静、李亚慧
 *
 * 如有任何疑问请联系：河北大学信管团队
 * QQ：196396337
 * Email:zagelover@163.com
 * HomePage：http://sxgzs.com/
 *
 * CopyRight (c) 河北大学信管团队 2010~2020
 */

using System;
using System.Data;
using System.Collections.Generic;
using IMIS_ERP.Model;
namespace IMIS_ERP.BLL
{
    /// <summary>Products_DisCount
    ///     <remarks>2011-01-21 河北大学信管团队</remarks>
    /// </summary>
    public class Products_DisCount
    {
        private readonly IMIS_ERP.DAL.Products_DisCount dal = new IMIS_ERP.DAL.Products_DisCount();
        public Products_DisCount()
        { }
        #region  Method

        /// <summary>是否存在该记录
        ///     <remarks>2011-01-21 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="pdID">编号</param>
        /// <returns>返回是否存在</returns>
        public bool Exists(int pdID)
        {
            return dal.Exists(pdID);
        }

        /// <summary>增加一条数据
        ///     <remarks>2011-01-21 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="model"></param>
        /// <returns>返回是否添加成功</returns>
        public bool Add(IMIS_ERP.Model.Products_DisCount model)
        {
            return dal.Add(model);
        }

        /// <summary>更新一条数据
        ///     <remarks>2011-01-21 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="model"></param>
        /// <returns>返回是否修改成功</returns>
        public bool Update(IMIS_ERP.Model.Products_DisCount model)
        {
            return dal.Update(model);
        }

        /// <summary>删除一条数据
        ///     <remarks>2011-01-21 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="pdID">编号</param>
        /// <returns>返回是否删除成功</returns>
        public bool Delete(string pdID)
        {

            return dal.Delete(pdID);
        }

        /// <summary>删除一条数据
        ///      <remarks>2011-01-21 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="pdID">编号</param>
        /// <returns>返回是否删除成功</returns>
        public string GetDisCount(string siID)
        {
            return dal.GetDisCount(siID);
        }

        /// <summary>批量删除记录
        ///     <remarks>2011-01-21 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="pdIDlist">编号列表</param>
        /// <returns>返回删除的记录条数</returns>
        public int DeleteList(string pdIDlist)
        {
            return dal.DeleteList(pdIDlist);
        }

        /// <summary>得到一个对象实体
        ///     <remarks>2011-01-21 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="pdID">编号</param>
        /// <returns>返回Model</returns>
        public IMIS_ERP.Model.Products_DisCount GetModel(int pdID)
        {

            return dal.GetModel(pdID);
        }

        /// <summary>获得数据列表
        ///     <remarks>2011-01-21 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="strWhere">查询条件</param>
        /// <returns>返回DataSet</returns>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }

        /// <summary>获得前几行数据
        ///     <remarks>2011-01-21 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="Top">行数</param>
        /// <param name="strWhere">条件</param>
        /// <param name="filedOrder">排序</param>
        /// <returns>返回DataSet</returns>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return dal.GetList(Top, strWhere, filedOrder);
        }
        /// <summary>获得数据列表
        ///     <remarks>2011-01-21 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="strWhere">条件</param>
        /// <returns>返回List</returns>
        public List<IMIS_ERP.Model.Products_DisCount> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }

        /// <summary>获得数据列表
        ///     <remarks>2011-01-21 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="dt">DataTable</param>
        /// <returns>返回List</returns>
        public List<IMIS_ERP.Model.Products_DisCount> DataTableToList(DataTable dt)
        {
            List<IMIS_ERP.Model.Products_DisCount> modelList = new List<IMIS_ERP.Model.Products_DisCount>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                IMIS_ERP.Model.Products_DisCount model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new IMIS_ERP.Model.Products_DisCount();
                    if (dt.Rows[n]["pdID"].ToString() != "")
                    {
                        model.pdID = int.Parse(dt.Rows[n]["pdID"].ToString());
                    }
                    model.pdProvince = dt.Rows[n]["pdProvince"].ToString();
                    model.pdCity = dt.Rows[n]["pdCity"].ToString();
                    model.pdArea = dt.Rows[n]["pdArea"].ToString();
                    model.pdPID = dt.Rows[n]["pdPID"].ToString();
                    if (dt.Rows[n]["pdDisCount"].ToString() != "")
                    {
                        model.pdDisCount = decimal.Parse(dt.Rows[n]["pdDisCount"].ToString());
                    }
                    if (dt.Rows[n]["pdBeginTime"].ToString() != "")
                    {
                        model.pdBeginTime = DateTime.Parse(dt.Rows[n]["pdBeginTime"].ToString());
                    }
                    if (dt.Rows[n]["pdEndTime"].ToString() != "")
                    {
                        model.pdEndTime = DateTime.Parse(dt.Rows[n]["pdEndTime"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>获得数据列表
        ///     <remarks>2011-01-21 河北大学信管团队</remarks>
        /// </summary>
        /// <returns>返回DataSet</returns>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>分页获取数据列表
        ///     <remarks>2011-01-21 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="PageSize">每页条数</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="strWhere">条件</param>
        /// <returns>返回DataSet</returns>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  Method
    }
}

